import pack from '/package.json'
// import { name as tagName } from '/package.json'
function createCompoent(data) {
  let com = {
    name: data.name,
    template: `
            <div class="async-route-container">
            <div>基座下显示子应用1</div>
            <${'micro-app-' + pack.name}
                baseroute="${data.baseroute}"
                :data="dataForChild"
                url="${data.url}"
                name="${pack.name + '-' + data.name}"
                keep-alive
            />
            </div>`,
    data: function () {
      return data
    },
  }
  //注册全局组件
  let isRegister = window.APP.component(data.name)
  if (isRegister) {
    console.log('组件名重复,注册失败', data.name)
  } else {
    window.APP.component(data.name, com)
    console.log('函数式注册了全局组件:', data.name)
  }
}

export default createCompoent
